package com.gy.api.mobile.huasu.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.fastjson.JSON;
import com.gy.api.base.ApiIndex;
import com.gy.api.base.HuaSuConstant;
import com.gy.api.base.R;
import com.gy.api.mobile.huasu.domain.FilmlVo;
import com.gy.util.HSClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/system/hs/huimin")
@RequiredArgsConstructor
@Api( tags = ApiIndex.H5_HuaSuController)
public class HuiminScreeningController {

    @Autowired
    private HSClient hsClient;

    @GetMapping("/getHuimin")
    @ApiOperation("惠民放映-获取华数电影-外部推荐")
    public R<List<FilmlVo>> getHuimin(){
        String moviePrefix = HuaSuConstant.MOVIE_PREFIX;
        R request = hsClient.getRequest(moviePrefix, FilmlVo.class, StpUtil.getTokenValue());
        Object data = request.getData();
        String json = JSON.toJSONString(data);
        return new R(JSON.parseArray(json, FilmlVo.class));
    }

}
